<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   主题：用R进行矩阵运算  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
   MathJax.Hub.Config({elements: ["bbpress-forums"]});
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://cos.name/cn/topic/3286/",
                  host: "http://cos.name",
                  prePath: "http://cos.name",
                  scheme: "http",
                  pathBase: "http://cos.name/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466437354: Accept with keywords: (title(0.333333333333):主题,矩阵,论坛, topn(0.433333333333):中求,线性方程组,帖子,项为,会员,行列式,行数,符号,性质,用户名,元素,行和列,维数,计算,向量,特征值,函数,特征向量,矩阵,单位矩阵,运算符,普通,算子,对称,主题,分解,列数,序列,对角,讨论区).-->
 </head>
 <body class="topic bbpress single single-topic postid-3286 single-author sidebar" onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    主题：用R进行矩阵运算
   </h1>
  </div>
  <div class="container" id="xmain">
   <div class="hfeed site" id="page">
    <header class="site-header" id="masthead" role="banner">
     <div id="cos-logo">
      <a href="http://cos.name/cn">
       <img src="http://cos.name/cn/wp-content/themes/COS-forest/images/headers/cos-logo.png"/>
      </a>
     </div>
     <div class="navbar" id="navbar">
      <nav class="navigation main-navigation" id="site-navigation" role="navigation">
       <h3 class="menu-toggle">
        菜单
       </h3>
       <div class="menu-%e8%8f%9c%e5%8d%951-container">
        <ul class="nav-menu" id="menu-%e8%8f%9c%e5%8d%951">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-407772" id="menu-item-407772">
          <a href="http://cos.name/cn/">
           论坛首页
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407773" id="menu-item-407773">
          <a href="http://cos.name/cn/forums/">
           讨论区
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407774" id="menu-item-407774">
          <a href="http://cos.name/cn/wp-login.php?action=register">
           注册
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407819" id="menu-item-407819">
          <a href="http://cos.name/">
           主站
          </a>
         </li>
        </ul>
       </div>
      </nav>
      <!-- #site-navigation -->
     </div>
     <!-- #navbar -->
    </header>
    <!-- #masthead -->
    <div class="site-main" id="main">
     <div class="content-area" id="primary">
      <div class="site-content" id="content" role="main">
       <article class="post-3286 topic type-topic status-publish hentry" id="post-3286">
        <header class="entry-header">
         <h1 class="entry-title">
          用R进行矩阵运算
         </h1>
        </header>
        <!-- .entry-header -->
        <div class="entry-content">
         <div id="bbpress-forums">
          <div class="bbp-breadcrumb">
           <p>
            <a class="bbp-breadcrumb-home" href="http://cos.name/cn/">
             COS论坛 | 统计之都
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-root" href="http://cos.name/cn/forums/">
             讨论区
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-forum" href="http://cos.name/cn/forum/software/">
             软件应用
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-forum" href="http://cos.name/cn/forum/software/r-language/">
             S-Plus &amp; R语言
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <span class="bbp-breadcrumb-current">
             用R进行矩阵运算
            </span>
           </p>
          </div>
          <div class="bbp-template-notice info">
           <p class="bbp-topic-description">
            该主题包含 40 条回复，29个帖子，最后由
            <a class="bbp-author-avatar" href="http://cos.name/cn/profile/shanfeng/" rel="nofollow" title="查看shanfeng的档案">
             <img src="http://sdn.geekzu.org/avatar/c35382b10db16521e4ca6b8433d0995d?s=14&amp;d=monsterid&amp;r=g"/>
            </a>
            <a class="bbp-author-name" href="http://cos.name/cn/profile/shanfeng/" rel="nofollow" title="查看shanfeng的档案">
             shanfeng
            </a>
            在
            <a href="http://cos.name/cn/topic/3286/page/3/#post-417331" title="回复：用R进行矩阵运算">
             1 周, 6 天 之前
            </a>
            更新。
           </p>
          </div>
          <div class="bbp-pagination">
           <div class="bbp-pagination-count">
            查看 15 个帖子 - 1 到 15（总计 41 个）
           </div>
           <div class="bbp-pagination-links">
            <span class="page-numbers current">
             1
            </span>
            <a class="page-numbers" href="http://cos.name/cn/topic/3286/page/2/">
             2
            </a>
            <a class="page-numbers" href="http://cos.name/cn/topic/3286/page/3/">
             3
            </a>
            <a class="next page-numbers" href="http://cos.name/cn/topic/3286/page/2/">
             →
            </a>
           </div>
          </div>
          <ul class="forums bbp-replies" id="topic-3286-replies">
           <li class="bbp-header">
            <div class="bbp-reply-author">
             作者
            </div>
            <!-- .bbp-reply-author -->
            <div class="bbp-reply-content">
             帖子
            </div>
            <!-- .bbp-reply-content -->
           </li>
           <!-- .bbp-header -->
           <li class="bbp-body">
            <div class="bbp-reply-header" id="post-3286">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月1日 下午11:17
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-3286">
               1 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-3286 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-1 user-id-3849 topic-author post-3286 topic type-topic status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               最近整理了一份R中矩阵运算的笔记，发上来供大家参考，若有错漏之处欢迎大家指正！
              </p>
              <p>
               主要包括以下内容：
              </p>
              <p>
               创建矩阵向量；矩阵加减，乘积；矩阵的逆；行列式的值；特征值与特征向量；QR分解；奇异值分解；广义逆；backsolve与fowardsolve函数；取矩阵的上下三角元素；向量化算子等
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217060">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:18
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217060">
               2 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217060 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-2 user-id-3849 topic-author post-217060 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                1    创建一个向量
               </strong>
               <br/>
               在R中可以用函数c()来创建一个向量，例如：
               <br/>
               &gt; x=c(1,2,3,4)
               <br/>
               &gt; x
               <br/>
               [1] 1 2 3 4
               <br/>
               <strong class="d4pbbc-bold">
                2    创建一个矩阵
               </strong>
               <br/>
               在R中可以用函数matrix()来创建一个矩阵，应用该函数时需要输入必要的参数值。
               <br/>
               &gt; args(matrix)
               <br/>
               function (data = NA, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)
               <br/>
               data项为必要的矩阵元素，nrow为行数，ncol为列数，注意nrow与ncol的乘积应为矩阵元素个数，byrow项控制排列元素时是否按行进行，dimnames给定行和列的名称。例如：
               <br/>
               &gt; matrix(1:12,nrow=3,ncol=4)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    4    7   10
               <br/>
               [2,]    2    5    8   11
               <br/>
               [3,]    3    6    9   12
               <br/>
               &gt; matrix(1:12,nrow=4,ncol=3)
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    5    9
               <br/>
               [2,]    2    6   10
               <br/>
               [3,]    3    7   11
               <br/>
               [4,]    4    8   12
               <br/>
               &gt; matrix(1:12,nrow=4,ncol=3,byrow=T)
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    2    3
               <br/>
               [2,]    4    5    6
               <br/>
               [3,]    7    8    9
               <br/>
               [4,]   10   11   12
               <br/>
               &gt; rowname
               <br/>
               [1] "r1" "r2" "r3"
               <br/>
               &gt; colname=c("c1","c2","c3","c4")
               <br/>
               &gt; colname
               <br/>
               [1] "c1" "c2" "c3" "c4"
               <br/>
               &gt; matrix(1:12,nrow=3,ncol=4,dimnames=list(rowname,colname))
               <br/>
               c1 c2 c3 c4
               <br/>
               r1  1  4  7 10
               <br/>
               r2  2  5  8 11
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217061">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:18
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217061">
               3 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217061 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-3 user-id-3849 topic-author post-217061 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                3    矩阵转置
               </strong>
               <br/>
               A为m×n矩阵，求A'在R中可用函数t()，例如：
               <br/>
               &gt; A=matrix(1:12,nrow=3,ncol=4)
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    4    7   10
               <br/>
               [2,]    2    5    8   11
               <br/>
               [3,]    3    6    9   12
               <br/>
               &gt; t(A)
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    2    3
               <br/>
               [2,]    4    5    6
               <br/>
               [3,]    7    8    9
               <br/>
               [4,]   10   11   12
               <br/>
               若将函数t()作用于一个向量x，则R默认x为列向量，返回结果为一个行向量，例如：
               <br/>
               &gt; x
               <br/>
               [1]  1  2  3  4  5  6  7  8  9 10
               <br/>
               &gt; t(x)
               <br/>
               [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
               <br/>
               [1,]    1    2    3    4    5    6    7    8    9    10
               <br/>
               &gt; class(x)
               <br/>
               [1] "integer"
               <br/>
               &gt; class(t(x))
               <br/>
               [1] "matrix"
               <br/>
               若想得到一个列向量，可用t(t(x))，例如：
              </p>
              <p>
               &gt; x
               <br/>
               [1]  1  2  3  4  5  6  7  8  9 10
               <br/>
               &gt; t(t(x))
               <br/>
               [,1]
               <br/>
               [1,]    1
               <br/>
               [2,]    2
               <br/>
               [3,]    3
               <br/>
               [4,]    4
               <br/>
               [5,]    5
               <br/>
               [6,]    6
               <br/>
               [7,]    7
               <br/>
               [8,]    8
               <br/>
               [9,]    9
               <br/>
               [10,]   10
               <br/>
               &gt; y=t(t(x))
               <br/>
               &gt; t(t(y))
               <br/>
               [,1]
               <br/>
               [1,]    1
               <br/>
               [2,]    2
               <br/>
               [3,]    3
               <br/>
               [4,]    4
               <br/>
               [5,]    5
               <br/>
               [6,]    6
               <br/>
               [7,]    7
               <br/>
               [8,]    8
               <br/>
               [9,]    9
               <br/>
               [10,]   10
               <br/>
               <strong class="d4pbbc-bold">
                4    矩阵相加减
               </strong>
               <br/>
               在R中对同行同列矩阵相加减，可用符号：“＋”、“－”，例如：
               <br/>
               &gt; A=B=matrix(1:12,nrow=3,ncol=4)
               <br/>
               &gt; A+B
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    8   14   20
               <br/>
               [2,]    4   10   16   22
               <br/>
               [3,]    6   12   18   24
               <br/>
               &gt; A-B
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    0    0    0    0
               <br/>
               [2,]    0    0    0    0
               <br/>
               [3,]    0    0    0    0
               <br/>
               <strong class="d4pbbc-bold">
                5    数与矩阵相乘
               </strong>
               <br/>
               A为m×n矩阵，c&gt;0，在R中求cA可用符号：“*”，例如：
               <br/>
               &gt; c=2
               <br/>
               &gt; c*A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    8   14   20
               <br/>
               [2,]    4   10   16   22
               <br/>
               [3,]    6   12   18   24
               <br/>
               <strong class="d4pbbc-bold">
                6    矩阵相乘
               </strong>
               <br/>
               A为m×n矩阵，B为n×k矩阵，在R中求AB可用符号：“％*％”，例如：
               <br/>
               &gt; A=matrix(1:12,nrow=3,ncol=4)
               <br/>
               &gt; B=matrix(1:12,nrow=4,ncol=3)
               <br/>
               &gt; A%*%B
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]   70  158  246
               <br/>
               [2,]   80  184  288
               <br/>
               [3,]   90  210  330
               <br/>
               若A为n×m矩阵，要得到A'B，可用函数crossprod() , 该函数计算结果与t(A)%*%B相同，但是效率更高。例如：
               <br/>
               &gt; A=matrix(1:12,nrow=4,ncol=3)
               <br/>
               &gt; B=matrix(1:12,nrow=4,ncol=3)
               <br/>
               &gt; t(A)%*%B
               <br/>
               [,1]  [,2]  [,3]
               <br/>
               [1,]   30   70  110
               <br/>
               [2,]   70  174  278
               <br/>
               [3,]  110  278  446
               <br/>
               &gt; crossprod(A,B)
               <br/>
               [,1]  [,2]  [,3]
               <br/>
               [1,]   30   70  110
               <br/>
               [2,]   70  174  278
               <br/>
               [3,]  110  278  446
               <br/>
               矩阵Hadamard积：若A={aij}m×n, B={bij}m×n, 则矩阵的Hadamard积定义为：
               <br/>
               A⊙B={aij bij }m×n,R中Hadamard积可以直接运用运算符“*”例如：
               <br/>
               &gt; A=matrix(1:16,4,4)
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    2    6   10   14
               <br/>
               [3,]    3    7   11   15
               <br/>
               [4,]    4    8   12   16
               <br/>
               &gt; B=A
               <br/>
               &gt; A*B
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1   25   81  169
               <br/>
               [2,]    4   36  100  196
               <br/>
               [3,]    9   49  121  225
               <br/>
               [4,]   16   64  144  256R中这两个运算符的区别区加以注意。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217062">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:19
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217062">
               4 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217062 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-4 user-id-3849 topic-author post-217062 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                7    矩阵对角元素相关运算
               </strong>
               <br/>
               例如要取一个方阵的对角元素，
               <br/>
               &gt; A=matrix(1:16,nrow=4,ncol=4)
               <br/>
               &gt; A
               <br/>
               [,1]  [,2]  [,3]  [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    2    6   10   14
               <br/>
               [3,]    3    7   11   15
               <br/>
               [4,]    4    8   12   16
               <br/>
               &gt; diag(A)
               <br/>
               [1]  1  6 11 16
               <br/>
               对一个向量应用diag()
               <br/>
               函数将产生以这个向量为对角元素的对角矩阵，例如：
               <br/>
               &gt; diag(diag(A))
               <br/>
               [,1]  [,2]  [,3]  [,4]
               <br/>
               [1,]    1    0    0    0
               <br/>
               [2,]    0    6    0    0
               <br/>
               [3,]    0    0   11    0
               <br/>
               [4,]    0    0    0   16
               <br/>
               对一个正整数z应用diag()函数将产生以z维单位矩阵，例如：
               <br/>
               &gt; diag(3)
               <br/>
               [,1]  [,2]  [,3]
               <br/>
               [1,]    1    0    0
               <br/>
               [2,]    0    1    0
               <br/>
               [3,]    0    0    1
               <br/>
               <strong class="d4pbbc-bold">
                8    矩阵求逆
               </strong>
               <br/>
               矩阵求逆可用函数solve()，应用solve(a, b)运算结果是解线性方程组ax = b，若b缺省，则系统默认为单位矩阵，因此可用其进行矩阵求逆，例如：
               <br/>
               &gt; a=matrix(rnorm(16),4,4)
               <br/>
               &gt; a
               <br/>
               [,1]       [,2]       [,3]       [,4]
               <br/>
               [1,] 1.6986019   0.5239738  0.2332094  0.3174184
               <br/>
               [2,] -0.2010667  1.0913013 -1.2093734   0.8096514
               <br/>
               [3,] -0.1797628  -0.7573283  0.2864535  1.3679963
               <br/>
               [4,] -0.2217916  -0.3754700  0.1696771 -1.2424030
               <br/>
               &gt; solve(a)
               <br/>
               [,1]        [,2]        [,3]       [,4]
               <br/>
               [1,]  0.9096360  0.54057479  0.7234861  1.3813059
               <br/>
               [2,] -0.6464172  -0.91849017  -1.7546836  -2.6957775
               <br/>
               [3,] -0.7841661  -1.78780083  -1.5795262  -3.1046207
               <br/>
               [4,] -0.0741260  -0.06308603  0.1854137  -0.6607851
               <br/>
               &gt; solve (a) %*%a
               <br/>
               [,1]          [,2]               [,3]          [,4]
               <br/>
               [1,] 1.000000e+00  2.748453e-17 -2.787755e-17 -8.023096e-17
               <br/>
               [2,] 1.626303e-19  1.000000e+00 -4.960225e-18  6.977925e-16
               <br/>
               [3,] 2.135878e-17 -4.629543e-17  1.000000e+00  6.201636e-17
               <br/>
               [4,] 1.866183e-17  1.563962e-17  1.183813e-17  1.000000e+00
               <br/>
               <strong class="d4pbbc-bold">
                9    矩阵的特征值与特征向量
               </strong>
               <br/>
               矩阵A的谱分解为A=UΛU',其中Λ是由A的特征值组成的对角矩阵，U的列为A的特征值对应的特征向量，在R中可以用函数eigen()函数得到U和Λ，
               <br/>
               &gt; args(eigen)
               <br/>
               function (x, symmetric, only.values = FALSE, EISPACK = FALSE)
               <br/>
               其中：x为矩阵，symmetric项指定矩阵x是否为对称矩阵，若不指定，系统将自动检测x是否为对称矩阵。例如：
               <br/>
               &gt; A=diag(4)+1
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    1    1    1
               <br/>
               [2,]    1    2    1    1
               <br/>
               [3,]    1    1    2    1
               <br/>
               [4,]    1    1    1    2
               <br/>
               &gt; A.eigen=eigen(A,symmetric=T)
               <br/>
               &gt; A.eigen
               <br/>
               $values
               <br/>
               [1] 5 1 1 1
              </p>
              <p>
               $vectors
               <br/>
               [,1]      [,2]          [,3]        [,4]
               <br/>
               [1,]  0.5  0.8660254  0.000000e+00  0.0000000
               <br/>
               [2,]  0.5 -0.2886751 -6.408849e-17  0.8164966
               <br/>
               [3,]  0.5 -0.2886751 -7.071068e-01 -0.4082483
               <br/>
               [4,]  0.5 -0.2886751  7.071068e-01 -0.4082483
              </p>
              <p>
               &gt; A.eigen$vectors%*%diag(A.eigen$values)%*%t(A.eigen$vectors)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    1    1    1
               <br/>
               [2,]    1    2    1    1
               <br/>
               [3,]    1    1    2    1
               <br/>
               [4,]    1    1    1    2
               <br/>
               &gt; t(A.eigen$vectors)%*%A.eigen$vectors
               <br/>
               [,1]           [,2]            [,3]            [,4]
               <br/>
               [1,]  1.000000e+00  4.377466e-17  1.626303e-17 -5.095750e-18
               <br/>
               [2,]  4.377466e-17  1.000000e+00 -1.694066e-18  6.349359e-18
               <br/>
               [3,]  1.626303e-17 -1.694066e-18  1.000000e+00 -1.088268e-16
               <br/>
               [4,] -5.095750e-18  6.349359e-18 -1.088268e-16  1.000000e+00
               <br/>
               <strong class="d4pbbc-bold">
                10    矩阵的Choleskey分解
               </strong>
               <br/>
               对于正定矩阵A，可对其进行Choleskey分解，即：A=P'P，其中P为上三角矩阵，在R中可以用函数chol()进行Choleskey分解，例如：
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    1    1    1
               <br/>
               [2,]    1    2    1    1
               <br/>
               [3,]    1    1    2    1
               <br/>
               [4,]    1    1    1    2
               <br/>
               &gt; chol(A)
               <br/>
               [,1]      [,2]      [,3]      [,4]
               <br/>
               [1,] 1.414214 0.7071068 0.7071068 0.7071068
               <br/>
               [2,] 0.000000 1.2247449 0.4082483 0.4082483
               <br/>
               [3,] 0.000000 0.0000000 1.1547005 0.2886751
               <br/>
               [4,] 0.000000 0.0000000 0.0000000 1.1180340
               <br/>
               &gt; t(chol(A))%*%chol(A)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    1    1    1
               <br/>
               [2,]    1    2    1    1
               <br/>
               [3,]    1    1    2    1
               <br/>
               [4,]    1    1    1    2
               <br/>
               &gt; crossprod(chol(A),chol(A))
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    1    1    1
               <br/>
               [2,]    1    2    1    1
               <br/>
               [3,]    1    1    2    1
               <br/>
               [4,]    1    1    1    2
               <br/>
               若矩阵为对称正定矩阵，可以利用Choleskey分解求行列式的值，如：
               <br/>
               &gt; prod(diag(chol(A))^2)
               <br/>
               [1] 5
               <br/>
               &gt; det(A)
               <br/>
               [1] 5
               <br/>
               若矩阵为对称正定矩阵，可以利用Choleskey分解求矩阵的逆，这时用函数chol2inv()，这种用法更有效。如：
               <br/>
               &gt; chol2inv(chol(A))
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]  0.8 -0.2 -0.2 -0.2
               <br/>
               [2,] -0.2  0.8 -0.2 -0.2
               <br/>
               [3,] -0.2 -0.2  0.8 -0.2
               <br/>
               [4,] -0.2 -0.2 -0.2  0.8
               <br/>
               &gt; solve(A)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]  0.8 -0.2 -0.2 -0.2
               <br/>
               [2,] -0.2  0.8 -0.2 -0.2
               <br/>
               [3,] -0.2 -0.2  0.8 -0.2
               <br/>
               [4,] -0.2 -0.2 -0.2  0.8
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217063">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:19
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217063">
               5 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217063 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-5 user-id-3849 topic-author post-217063 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                11    矩阵奇异值分解
               </strong>
               <br/>
               A为m×n矩阵，rank(A)= r, 可以分解为：A=UDV',其中U'U=V'V=I。在R中可以用函数scd()进行奇异值分解，例如：
               <br/>
               &gt; A=matrix(1:18,3,6)
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4] [,5] [,6]
               <br/>
               [1,]    1    4    7   10   13   16
               <br/>
               [2,]    2    5    8   11   14   17
               <br/>
               [3,]    3    6    9   12   15   18
               <br/>
               &gt; svd(A)
               <br/>
               $d
               <br/>
               [1] 4.589453e+01 1.640705e+00 3.627301e-16
               <br/>
               $u
               <br/>
               [,1]        [,2]       [,3]
               <br/>
               [1,] -0.5290354  0.74394551  0.4082483
               <br/>
               [2,] -0.5760715  0.03840487 -0.8164966
               <br/>
               [3,] -0.6231077 -0.66713577  0.4082483
               <br/>
               $v
               <br/>
               [,1]       [,2]        [,3]
               <br/>
               [1,] -0.07736219 -0.7196003 -0.18918124
               <br/>
               [2,] -0.19033085 -0.5089325  0.42405898
               <br/>
               [3,] -0.30329950 -0.2982646 -0.45330031
               <br/>
               [4,] -0.41626816 -0.0875968 -0.01637004
               <br/>
               [5,] -0.52923682  0.1230711  0.64231130
               <br/>
               [6,] -0.64220548  0.3337389 -0.40751869
               <br/>
               &gt; A.svd=svd(A)
               <br/>
               &gt; A.svd$u%*%diag(A.svd$d)%*%t(A.svd$v)
               <br/>
               [,1] [,2] [,3] [,4] [,5] [,6]
               <br/>
               [1,]    1    4    7   10   13   16
               <br/>
               [2,]    2    5    8   11   14   17
               <br/>
               [3,]    3    6    9   12   15   18
               <br/>
               &gt; t(A.svd$u)%*%A.svd$u
               <br/>
               [,1]          [,2]          [,3]
               <br/>
               [1,]  1.000000e+00 -1.169312e-16 -3.016793e-17
               <br/>
               [2,] -1.169312e-16  1.000000e+00 -3.678156e-17
               <br/>
               [3,] -3.016793e-17 -3.678156e-17  1.000000e+00
               <br/>
               &gt; t(A.svd$v)%*%A.svd$v
               <br/>
               [,1]          [,2]          [,3]
               <br/>
               [1,]  1.000000e+00  8.248068e-17 -3.903128e-18
               <br/>
               [2,]  8.248068e-17  1.000000e+00 -2.103352e-17
               <br/>
               [3,] -3.903128e-18 -2.103352e-17  1.000000e+00
               <br/>
               <strong class="d4pbbc-bold">
                12    矩阵QR分解
               </strong>
               <br/>
               A为m×n矩阵可以进行QR分解，A=QR，其中：Q'Q＝I，在R中可以用函数qr()进行QR分解，例如：
               <br/>
               &gt; A=matrix(1:16,4,4)
               <br/>
               &gt; qr(A)
               <br/>
               $qr
               <br/>
               [,1]        [,2]          [,3]          [,4]
               <br/>
               [1,] -5.4772256 -12.7801930 -2.008316e+01 -2.738613e+01
               <br/>
               [2,]  0.3651484  -3.2659863 -6.531973e+00 -9.797959e+00
               <br/>
               [3,]  0.5477226  -0.3781696  2.641083e-15  2.056562e-15
               <br/>
               [4,]  0.7302967  -0.9124744  8.583032e-01 -2.111449e-16
              </p>
              <p>
               $rank
               <br/>
               [1] 2
              </p>
              <p>
               $qraux
               <br/>
               [1] 1.182574e+00 1.156135e+00 1.513143e+00 2.111449e-16
              </p>
              <p>
               $pivot
               <br/>
               [1] 1 2 3 4
              </p>
              <p>
               attr(,"class")
               <br/>
               [1] "qr"
               <br/>
               rank项返回矩阵的秩，qr项包含了矩阵Q和R的信息，要得到矩阵Q和R，可以用函数qr.Q()和qr.R()作用qr()的返回结果，例如：
               <br/>
               &gt; qr.R(qr(A))
               <br/>
               [,1]       [,2]          [,3]          [,4]
               <br/>
               [1,] -5.477226 -12.780193 -2.008316e+01 -2.738613e+01
               <br/>
               [2,]  0.000000  -3.265986 -6.531973e+00 -9.797959e+00
               <br/>
               [3,]  0.000000   0.000000  2.641083e-15  2.056562e-15
               <br/>
               [4,]  0.000000   0.000000  0.000000e+00 -2.111449e-16
               <br/>
               &gt; qr.Q(qr(A))
               <br/>
               [,1]          [,2]       [,3]        [,4]
               <br/>
               [1,] -0.1825742 -8.164966e-01 -0.4000874 -0.37407225
               <br/>
               [2,] -0.3651484 -4.082483e-01  0.2546329  0.79697056
               <br/>
               [3,] -0.5477226 -8.131516e-19  0.6909965 -0.47172438
               <br/>
               [4,] -0.7302967  4.082483e-01 -0.5455419  0.04882607
               <br/>
               &gt; qr.Q(qr(A))%*%qr.R(qr(A))
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    2    6   10   14
               <br/>
               [3,]    3    7   11   15
               <br/>
               [4,]    4    8   12   16
               <br/>
               &gt; t(qr.Q(qr(A)))%*%qr.Q(qr(A))
               <br/>
               [,1]          [,2]          [,3]          [,4]
               <br/>
               [1,]  1.000000e+00 -1.457168e-16 -6.760001e-17 -7.659550e-17
               <br/>
               [2,] -1.457168e-16  1.000000e+00 -4.269046e-17  7.011739e-17
               <br/>
               [3,] -6.760001e-17 -4.269046e-17  1.000000e+00 -1.596437e-16
               <br/>
               [4,] -7.659550e-17  7.011739e-17 -1.596437e-16  1.000000e+00
               <br/>
               &gt; qr.X(qr(A))
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    2    6   10   14
               <br/>
               [3,]    3    7   11   15
               <br/>
               [4,]    4    8   12   16
               <br/>
               <strong class="d4pbbc-bold">
                13    矩阵广义逆(Moore-Penrose)
               </strong>
               <br/>
               n×m矩阵A+称为m×n矩阵A的Moore-Penrose逆，如果它满足下列条件：
               <br/>
               ①    A A+A=A；②A+A A+= A+；③(A A+)H=A A+；④(A+A)H= A+A
               <br/>
               在R的MASS包中的函数ginv()可计算矩阵A的Moore-Penrose逆，例如：
               <br/>
               library(“MASS”)
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    2    6   10   14
               <br/>
               [3,]    3    7   11   15
               <br/>
               [4,]    4    8   12   16
               <br/>
               &gt; ginv(A)
               <br/>
               [,1]    [,2]  [,3]    [,4]
               <br/>
               [1,] -0.285 -0.1075  0.07  0.2475
               <br/>
               [2,] -0.145 -0.0525  0.04  0.1325
               <br/>
               [3,] -0.005  0.0025  0.01  0.0175
               <br/>
               [4,]  0.135  0.0575 -0.02 -0.0975
               <br/>
               验证性质1：
               <br/>
               &gt; A%*%ginv(A)%*%A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    2    6   10   14
               <br/>
               [3,]    3    7   11   15
               <br/>
               [4,]    4    8   12   16
               <br/>
               验证性质2：
               <br/>
               &gt; ginv(A)%*%A%*%ginv(A)
               <br/>
               [,1]    [,2]  [,3]    [,4]
               <br/>
               [1,] -0.285 -0.1075  0.07  0.2475
               <br/>
               [2,] -0.145 -0.0525  0.04  0.1325
               <br/>
               [3,] -0.005  0.0025  0.01  0.0175
               <br/>
               [4,]  0.135  0.0575 -0.02 -0.0975
               <br/>
               验证性质3:
               <br/>
               &gt; t(A%*%ginv(A))
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]  0.7  0.4  0.1 -0.2
               <br/>
               [2,]  0.4  0.3  0.2  0.1
               <br/>
               [3,]  0.1  0.2  0.3  0.4
               <br/>
               [4,] -0.2  0.1  0.4  0.7
               <br/>
               &gt; A%*%ginv(A)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]  0.7  0.4  0.1 -0.2
               <br/>
               [2,]  0.4  0.3  0.2  0.1
               <br/>
               [3,]  0.1  0.2  0.3  0.4
               <br/>
               [4,] -0.2  0.1  0.4  0.7
               <br/>
               验证性质4:
               <br/>
               &gt; t(ginv(A)%*%A)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]  0.7  0.4  0.1 -0.2
               <br/>
               [2,]  0.4  0.3  0.2  0.1
               <br/>
               [3,]  0.1  0.2  0.3  0.4
               <br/>
               [4,] -0.2  0.1  0.4  0.7
               <br/>
               &gt; ginv(A)%*%A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]  0.7  0.4  0.1 -0.2
               <br/>
               [2,]  0.4  0.3  0.2  0.1
               <br/>
               [3,]  0.1  0.2  0.3  0.4
               <br/>
               [4,] -0.2  0.1  0.4  0.7
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217064">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:20
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217064">
               6 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217064 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-6 user-id-3849 topic-author post-217064 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                14    矩阵Kronecker积
               </strong>
               <br/>
               n×m矩阵A与h×k矩阵B的kronecker积为一个nh×mk维矩阵，
               <br/>
               在R中kronecker积可以用函数kronecker()来计算，例如：
               <br/>
               &gt; A=matrix(1:4,2,2)
               <br/>
               &gt; B=matrix(rep(1,4),2,2)
               <br/>
               &gt; A
               <br/>
               [,1] [,2]
               <br/>
               [1,]    1    3
               <br/>
               [2,]    2    4
               <br/>
               &gt; B
               <br/>
               [,1] [,2]
               <br/>
               [1,]    1    1
               <br/>
               [2,]    1    1
               <br/>
               &gt; kronecker(A,B)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    1    3    3
               <br/>
               [2,]    1    1    3    3
               <br/>
               [3,]    2    2    4    4
               <br/>
               [4,]    2    2    4    4
               <br/>
               <strong class="d4pbbc-bold">
                15    矩阵的维数
               </strong>
               <br/>
               在R中很容易得到一个矩阵的维数，函数dim()将返回一个矩阵的维数，nrow()返回行数，ncol()返回列数，例如：
               <br/>
               &gt; A=matrix(1:12,3,4)
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    4    7   10
               <br/>
               [2,]    2    5    8   11
               <br/>
               [3,]    3    6    9   12
               <br/>
               &gt; nrow(A)
               <br/>
               [1] 3
               <br/>
               &gt; ncol(A)
               <br/>
               [1] 4
               <br/>
               <strong class="d4pbbc-bold">
                16    矩阵的行和、列和、行平均与列平均
               </strong>
               <br/>
               在R中很容易求得一个矩阵的各行的和、平均数与列的和、平均数，例如：
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    4    7   10
               <br/>
               [2,]    2    5    8   11
               <br/>
               [3,]    3    6    9   12
               <br/>
               &gt; rowSums(A)
               <br/>
               [1] 22 26 30
               <br/>
               &gt; rowMeans(A)
               <br/>
               [1] 5.5 6.5 7.5
               <br/>
               &gt; colSums(A)
               <br/>
               [1]  6 15 24 33
               <br/>
               &gt; colMeans(A)
               <br/>
               [1]  2  5  8 11
               <br/>
               上述关于矩阵行和列的操作，还可以使用apply()函数实现。
               <br/>
               &gt; args(apply)
               <br/>
               function (X, MARGIN, FUN, …)
               <br/>
               其中：x为矩阵，MARGIN用来指定是对行运算还是对列运算，MARGIN＝1表示对行运算，MARGIN＝2表示对列运算，FUN用来指定运算函数，。…用来给定FUN中需要的其它的参数，例如：
               <br/>
               &gt; apply(A,1,sum)
               <br/>
               [1] 22 26 30
               <br/>
               &gt; apply(A,1,mean)
               <br/>
               [1] 5.5 6.5 7.5
               <br/>
               &gt; apply(A,2,sum)
               <br/>
               [1]  6 15 24 33
               <br/>
               &gt; apply(A,2,mean)
               <br/>
               [1]  2  5  8 11
               <br/>
               apply()函数功能强大，我们可以对矩阵的行或者列进行其它运算，例如：
               <br/>
               计算每一列的方差
               <br/>
               &gt; A=matrix(rnorm(100),20,5)
               <br/>
               &gt; apply(A,2,var)
               <br/>
               [1] 0.4641787 1.4331070 0.3186012 1.3042711 0.5238485
               <br/>
               &gt; apply(A,2,function(x,a)x*a,a=2)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    2    8   14   20
               <br/>
               [2,]    4   10   16   22
               <br/>
               [3,]    6   12   18   24
               <br/>
               注意：apply(A,2,function(x,a)x*a,a=2)与A*2效果相同，此处旨在说明如何应用alpply函数。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217065">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:21
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217065">
               7 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217065 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-7 user-id-3849 topic-author post-217065 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                17    矩阵X'X的逆
               </strong>
               <br/>
               在统计计算中，我们常常需要计算这样矩阵的逆，如OLS估计中求系数矩阵。R中的包“strucchange”提供了有效的计算方法。
               <br/>
               &gt; args(solveCrossprod)
               <br/>
               function (X, method = c("qr", "chol", "solve"))
               <br/>
               其中：method指定求逆方法，选用“qr”效率最高，选用“chol”精度最高，选用“slove”与slove(crossprod(x,x))效果相同，例如：
               <br/>
               &gt; A=matrix(rnorm(16),4,4)
               <br/>
               &gt; solveCrossprod(A,method="qr")
               <br/>
               [,1]       [,2]       [,3]       [,4]
               <br/>
               [1,]  0.6132102 -0.1543924 -0.2900796  0.2054730
               <br/>
               [2,] -0.1543924  0.4779277  0.1859490 -0.2097302
               <br/>
               [3,] -0.2900796  0.1859490  0.6931232 -0.3162961
               <br/>
               [4,]  0.2054730 -0.2097302 -0.3162961  0.3447627
               <br/>
               &gt; solveCrossprod(A,method="chol")
               <br/>
               [,1]       [,2]       [,3]       [,4]
               <br/>
               [1,]  0.6132102 -0.1543924 -0.2900796  0.2054730
               <br/>
               [2,] -0.1543924  0.4779277  0.1859490 -0.2097302
               <br/>
               [3,] -0.2900796  0.1859490  0.6931232 -0.3162961
               <br/>
               [4,]  0.2054730 -0.2097302 -0.3162961  0.3447627
               <br/>
               &gt; solveCrossprod(A,method="solve")
               <br/>
               [,1]       [,2]       [,3]       [,4]
               <br/>
               [1,]  0.6132102 -0.1543924 -0.2900796  0.2054730
               <br/>
               [2,] -0.1543924  0.4779277  0.1859490 -0.2097302
               <br/>
               [3,] -0.2900796  0.1859490  0.6931232 -0.3162961
               <br/>
               [4,]  0.2054730 -0.2097302 -0.3162961  0.3447627
               <br/>
               &gt; solve(crossprod(A,A))
               <br/>
               [,1]       [,2]       [,3]       [,4]
               <br/>
               [1,]  0.6132102 -0.1543924 -0.2900796  0.2054730
               <br/>
               [2,] -0.1543924  0.4779277  0.1859490 -0.2097302
               <br/>
               [3,] -0.2900796  0.1859490  0.6931232 -0.3162961
               <br/>
               [4,]  0.2054730 -0.2097302 -0.3162961  0.3447627
               <br/>
               <strong class="d4pbbc-bold">
                18    取矩阵的上、下三角部分
               </strong>
               <br/>
               在R中，我们可以很方便的取到一个矩阵的上、下三角部分的元素，函数lower.tri()和函数upper.tri()提供了有效的方法。
               <br/>
               &gt; args(lower.tri)
               <br/>
               function (x, diag = FALSE)
               <br/>
               函数将返回一个逻辑值矩阵，其中下三角部分为真，上三角部分为假，选项diag为真时包含对角元素，为假时不包含对角元素。upper.tri()的效果与之孑然相反。例如：
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    2    6   10   14
               <br/>
               [3,]    3    7   11   15
               <br/>
               [4,]    4    8   12   16
               <br/>
               &gt; lower.tri(A)
               <br/>
               [,1]  [,2]  [,3]  [,4]
               <br/>
               [1,] FALSE FALSE FALSE FALSE
               <br/>
               [2,]  TRUE FALSE FALSE FALSE
               <br/>
               [3,]  TRUE  TRUE FALSE FALSE
               <br/>
               [4,]  TRUE  TRUE  TRUE FALSE
               <br/>
               &gt; lower.tri(A,diag=T)
               <br/>
               [,1]  [,2]  [,3]  [,4]
               <br/>
               [1,] TRUE FALSE FALSE FALSE
               <br/>
               [2,] TRUE  TRUE FALSE FALSE
               <br/>
               [3,] TRUE  TRUE  TRUE FALSE
               <br/>
               [4,] TRUE  TRUE  TRUE  TRUE
               <br/>
               &gt; upper.tri(A)
               <br/>
               [,1]  [,2]  [,3]  [,4]
               <br/>
               [1,] FALSE  TRUE  TRUE  TRUE
               <br/>
               [2,] FALSE FALSE  TRUE  TRUE
               <br/>
               [3,] FALSE FALSE FALSE  TRUE
               <br/>
               [4,] FALSE FALSE FALSE FALSE
               <br/>
               &gt; upper.tri(A,diag=T)
               <br/>
               [,1]  [,2]  [,3] [,4]
               <br/>
               [1,]  TRUE  TRUE  TRUE TRUE
               <br/>
               [2,] FALSE  TRUE  TRUE TRUE
               <br/>
               [3,] FALSE FALSE  TRUE TRUE
               <br/>
               [4,] FALSE FALSE FALSE TRUE
               <br/>
               &gt; A[lower.tri(A)]=0
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    5    9   13
               <br/>
               [2,]    0    6   10   14
               <br/>
               [3,]    0    0   11   15
               <br/>
               [4,]    0    0    0   16
               <br/>
               &gt; A[upper.tri(A)]=0
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    0    0    0
               <br/>
               [2,]    2    6    0    0
               <br/>
               [3,]    3    7   11    0
               <br/>
               [4,]    4    8   12   16
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217067">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:38
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217067">
               8 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217067 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-8 user-id-3849 topic-author post-217067 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                19    backsolve&amp;fowardsolve函数
               </strong>
               <br/>
               这两个函数用于解特殊线性方程组，其特殊之处在于系数矩阵为上或下三角。
               <br/>
               &gt; args(backsolve)
               <br/>
               function (r, x, k = ncol(r), upper.tri = TRUE, transpose = FALSE)
               <br/>
               &gt; args(forwardsolve)
               <br/>
               function (l, x, k = ncol(l), upper.tri = FALSE, transpose = FALSE)
               <br/>
               其中：r或者l为n×n维三角矩阵，x为n×1维向量，对给定不同的upper.tri和transpose的值，方程的形式不同
               <br/>
               对于函数backsolve()而言，
               <br/>
               例如：
               <br/>
               &gt; A=matrix(1:9,3,3)
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    4    7
               <br/>
               [2,]    2    5    8
               <br/>
               [3,]    3    6    9
               <br/>
               &gt; x=c(1,2,3)
               <br/>
               &gt; x
               <br/>
               [1] 1 2 3
               <br/>
               &gt; B=A
               <br/>
               &gt; B[upper.tri(B)]=0
               <br/>
               &gt; B
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    0    0
               <br/>
               [2,]    2    5    0
               <br/>
               [3,]    3    6    9
               <br/>
               &gt; C=A
               <br/>
               &gt; C[lower.tri(C)]=0
               <br/>
               &gt; C
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    4    7
               <br/>
               [2,]    0    5    8
               <br/>
               [3,]    0    0    9
               <br/>
               &gt; backsolve(A,x,upper.tri=T,transpose=T)
               <br/>
               [1]  1.00000000 -0.40000000 -0.08888889
               <br/>
               &gt; solve(t(C),x)
               <br/>
               [1]  1.00000000 -0.40000000 -0.08888889
               <br/>
               &gt; backsolve(A,x,upper.tri=T,transpose=F)
               <br/>
               [1] -0.8000000 -0.1333333  0.3333333
               <br/>
               &gt; solve(C,x)
               <br/>
               [1] -0.8000000 -0.1333333  0.3333333
               <br/>
               &gt; backsolve(A,x,upper.tri=F,transpose=T)
               <br/>
               [1] 1.111307e-17 2.220446e-17 3.333333e-01
               <br/>
               &gt; solve(t(B),x)
               <br/>
               [1] 1.110223e-17 2.220446e-17 3.333333e-01
               <br/>
               &gt; backsolve(A,x,upper.tri=F,transpose=F)
               <br/>
               [1] 1 0 0
               <br/>
               &gt; solve(B,x)
               <br/>
               [1]  1.000000e+00 -1.540744e-33 -1.850372e-17
               <br/>
               对于函数forwardsolve()而言，
               <br/>
               例如：
               <br/>
               &gt; A
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    4    7
               <br/>
               [2,]    2    5    8
               <br/>
               [3,]    3    6    9
               <br/>
               &gt; B
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    0    0
               <br/>
               [2,]    2    5    0
               <br/>
               [3,]    3    6    9
               <br/>
               &gt; C
               <br/>
               [,1] [,2] [,3]
               <br/>
               [1,]    1    4    7
               <br/>
               [2,]    0    5    8
               <br/>
               [3,]    0    0    9
               <br/>
               &gt; x
               <br/>
               [1] 1 2 3
               <br/>
               &gt; forwardsolve(A,x,upper.tri=T,transpose=T)
               <br/>
               [1]  1.00000000 -0.40000000 -0.08888889
               <br/>
               &gt; solve(t(C),x)
               <br/>
               [1]  1.00000000 -0.40000000 -0.08888889
               <br/>
               &gt; forwardsolve(A,x,upper.tri=T,transpose=F)
               <br/>
               [1] -0.8000000 -0.1333333  0.3333333
               <br/>
               &gt; solve(C,x)
               <br/>
               [1] -0.8000000 -0.1333333  0.3333333
               <br/>
               &gt; forwardsolve(A,x,upper.tri=F,transpose=T)
               <br/>
               [1] 1.111307e-17 2.220446e-17 3.333333e-01
               <br/>
               &gt; solve(t(B),x)
               <br/>
               [1] 1.110223e-17 2.220446e-17 3.333333e-01
               <br/>
               &gt; forwardsolve(A,x,upper.tri=F,transpose=F)
               <br/>
               [1] 1 0 0
               <br/>
               &gt; solve(B,x)
               <br/>
               [1]  1.000000e+00 -1.540744e-33 -1.850372e-17
               <br/>
               <strong class="d4pbbc-bold">
                20    row()与col()函数
               </strong>
               <br/>
               在R中定义了的这两个函数用于取矩阵元素的行或列下标矩阵，例如矩阵A={aij}m×n，
               <br/>
               row()函数将返回一个与矩阵A有相同维数的矩阵，该矩阵的第i行第j列元素为i，函数col()类似。例如：
               <br/>
               &gt; x=matrix(1:12,3,4)
               <br/>
               &gt; row(x)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    1    1    1
               <br/>
               [2,]    2    2    2    2
               <br/>
               [3,]    3    3    3    3
               <br/>
               &gt; col(x)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    2    3    4
               <br/>
               [2,]    1    2    3    4
               <br/>
               [3,]    1    2    3    4
               <br/>
               这两个函数同样可以用于取一个矩阵的上下三角矩阵，例如：
               <br/>
               &gt; x
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    4    7   10
               <br/>
               [2,]    2    5    8   11
               <br/>
               [3,]    3    6    9   12
               <br/>
               &gt; x[row(x)&lt;col(x)]=0
               <br/>
               &gt; x
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    0    0    0
               <br/>
               [2,]    2    5    0    0
               <br/>
               [3,]    3    6    9    0
               <br/>
               &gt; x=matrix(1:12,3,4)
               <br/>
               &gt; x[row(x)&gt;col(x)]=0
               <br/>
               &gt; x
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    4    7   10
               <br/>
               [2,]    0    5    8   11
               <br/>
               [3,]    0    0    9   12
               <br/>
               <strong class="d4pbbc-bold">
                21    行列式的值
               </strong>
               <br/>
               在R中，函数det(x)将计算方阵x的行列式的值，例如：
               <br/>
               &gt; x=matrix(rnorm(16),4,4)
               <br/>
               &gt; x
               <br/>
               [,1]       [,2]       [,3]        [,4]
               <br/>
               [1,] -1.0736375  0.2809563 -1.5796854  0.51810378
               <br/>
               [2,] -1.6229898 -0.4175977  1.2038194 -0.06394986
               <br/>
               [3,] -0.3989073 -0.8368334 -0.6374909 -0.23657088
               <br/>
               [4,]  1.9413061  0.8338065 -1.5877162 -1.30568465
               <br/>
               &gt; det(x)
               <br/>
               [1] 5.717667
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217068">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午6:41
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217068">
               9 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217068 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-9 user-id-3849 topic-author post-217068 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               <strong class="d4pbbc-bold">
                22向量化算子
               </strong>
               <br/>
               在R中可以很容易的实现向量化算子，例如：
              </p>
              <pre class="highlight ">vec&lt;-function (x) {
      t(t(as.vector(x)))
}
</pre>
              <p>
              </p>
              <pre class="highlight ">vech&lt;-function (x) {
       t(x[lower.tri(x,diag=T)])
}
</pre>
              <p>
               &gt; x=matrix(1:12,3,4)
               <br/>
               &gt; x
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    1    4    7   10
               <br/>
               [2,]    2    5    8   11
               <br/>
               [3,]    3    6    9   12
               <br/>
               &gt; vec(x)
               <br/>
               [,1]
               <br/>
               [1,]    1
               <br/>
               [2,]    2
               <br/>
               [3,]    3
               <br/>
               [4,]    4
               <br/>
               [5,]    5
               <br/>
               [6,]    6
               <br/>
               [7,]    7
               <br/>
               [8,]    8
               <br/>
               [9,]    9
               <br/>
               [10,]   10
               <br/>
               [11,]   11
               <br/>
               [12,]   12
               <br/>
               &gt; vech(x)
               <br/>
               [,1] [,2] [,3] [,4] [,5] [,6]
               <br/>
               [1,]    1    2    3    5    6    9
               <br/>
               <strong class="d4pbbc-bold">
                23    时间序列的滞后值
               </strong>
               <br/>
               在时间序列分析中，我们常常要用到一个序列的滞后序列，R中的包“fMultivar”中的函数tslag()提供了这个功能。
               <br/>
               &gt; args(tslag)
               <br/>
               function (x, k = 1, trim = FALSE)
               <br/>
               其中：x为一个向量，k指定滞后阶数，可以是一个自然数列，若trim为假，则返回序列与原序列长度相同，但含有NA值；若trim项为真，则返回序列中不含有NA值，例如：
               <br/>
               &gt; x=1:20
               <br/>
               &gt; tslag(x,1:4,trim=F)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]   NA   NA   NA   NA
               <br/>
               [2,]    1   NA   NA   NA
               <br/>
               [3,]    2    1   NA   NA
               <br/>
               [4,]    3    2    1   NA
               <br/>
               [5,]    4    3    2    1
               <br/>
               [6,]    5    4    3    2
               <br/>
               [7,]    6    5    4    3
               <br/>
               [8,]    7    6    5    4
               <br/>
               [9,]    8    7    6    5
               <br/>
               [10,]    9    8    7    6
               <br/>
               [11,]   10    9    8    7
               <br/>
               [12,]   11   10    9    8
               <br/>
               [13,]   12   11   10    9
               <br/>
               [14,]   13   12   11   10
               <br/>
               [15,]   14   13   12   11
               <br/>
               [16,]   15   14   13   12
               <br/>
               [17,]   16   15   14   13
               <br/>
               [18,]   17   16   15   14
               <br/>
               [19,]   18   17   16   15
               <br/>
               [20,]   19   18   17   16
               <br/>
               &gt; tslag(x,1:4,trim=T)
               <br/>
               [,1] [,2] [,3] [,4]
               <br/>
               [1,]    4    3    2    1
               <br/>
               [2,]    5    4    3    2
               <br/>
               [3,]    6    5    4    3
               <br/>
               [4,]    7    6    5    4
               <br/>
               [5,]    8    7    6    5
               <br/>
               [6,]    9    8    7    6
               <br/>
               [7,]   10    9    8    7
               <br/>
               [8,]   11   10    9    8
               <br/>
               [9,]   12   11   10    9
               <br/>
               [10,]   13   12   11   10
               <br/>
               [11,]   14   13   12   11
               <br/>
               [12,]   15   14   13   12
               <br/>
               [13,]   16   15   14   13
               <br/>
               [14,]   17   16   15   14
               <br/>
               [15,]   18   17   16   15
               <br/>
               [16,]   19   18   17   16
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217074">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午8:08
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217074">
               10 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217074 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-10 user-id-230 post-217074 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/230/" rel="nofollow" title="查看Rtist的档案">
               <img src="http://sdn.geekzu.org/avatar/3cf69793b8d5be8febd22526bae3bb10?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/230/" rel="nofollow" title="查看Rtist的档案">
               Rtist
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               Very good~~
              </p>
              <p>
               Some trivial comments:
               <br/>
               outer() or %o% for outer products;
               <br/>
               kronecker() could be used as %x% in most cases;
               <br/>
               The efficiency and accuracy is reversed for "qr" and "chol" in solveCrossprod() according to its help;
               <br/>
               The fastest way to get a vector from a matrix is not as.vector(A), but {tmp=A;dim(tmp)=NULL;tmp}.
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217083">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午9:40
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217083">
               11 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217083 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-11 user-id-3849 topic-author post-217083 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               <img src="http://sdn.geekzu.org/avatar/f8d6415705583cd10615d52a1b6797db?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3849/" rel="nofollow" title="查看anning189的档案">
               anning189
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               多谢指正，我会改进
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217089">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 上午11:10
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217089">
               12 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217089 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-12 user-id-1754 post-217089 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/1754/" rel="nofollow" title="查看ilikemath的档案">
               <img src="http://sdn.geekzu.org/avatar/578766bcdea055ce613a51dc290ab1c4?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/1754/" rel="nofollow" title="查看ilikemath的档案">
               ilikemath
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               不错，就是应该说教结合，有例子最好，支持！
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217105">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月2日 下午6:01
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217105">
               13 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217105 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-13 user-id-3878 post-217105 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3878/" rel="nofollow" title="查看areg的档案">
               <img src="http://sdn.geekzu.org/avatar/b46e95d66e3bc69f588b9f002f09b1ce?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3878/" rel="nofollow" title="查看areg的档案">
               areg
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               支持
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217110">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月3日 上午2:20
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217110">
               14 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217110 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-14 user-id-3 post-217110 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/3/" rel="nofollow" title="查看eshanzi的档案">
               <img src="http://sdn.geekzu.org/avatar/b9f874e100c673f648bddd31914a7de2?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/3/" rel="nofollow" title="查看eshanzi的档案">
               eshanzi
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               不错不错，一件很好的工作，谢谢楼主
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-217120">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2007年1月3日 上午6:30
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/3286/#post-217120">
               15 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-217120 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-3286 bbp-reply-position-15 user-id-5479 post-217120 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/5479/" rel="nofollow" title="查看coddz的档案">
               <img src="http://sdn.geekzu.org/avatar/a92ea8f738d98da5828c2e9bf26aff2a?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/5479/" rel="nofollow" title="查看coddz的档案">
               coddz
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               谢谢LZ，再接再厉。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
           </li>
           <!-- .bbp-body -->
           <li class="bbp-footer">
            <div class="bbp-reply-author">
             作者
            </div>
            <div class="bbp-reply-content">
             帖子
            </div>
            <!-- .bbp-reply-content -->
           </li>
           <!-- .bbp-footer -->
          </ul>
          <!-- #topic-3286-replies -->
          <div class="bbp-pagination">
           <div class="bbp-pagination-count">
            查看 15 个帖子 - 1 到 15（总计 41 个）
           </div>
           <div class="bbp-pagination-links">
            <span class="page-numbers current">
             1
            </span>
            <a class="page-numbers" href="http://cos.name/cn/topic/3286/page/2/">
             2
            </a>
            <a class="page-numbers" href="http://cos.name/cn/topic/3286/page/3/">
             3
            </a>
            <a class="next page-numbers" href="http://cos.name/cn/topic/3286/page/2/">
             →
            </a>
           </div>
          </div>
          <div class="bbp-no-reply" id="no-reply-3286">
           <div class="bbp-template-notice">
            <p>
             您必须先登录才能回复该主题。
            </p>
           </div>
          </div>
         </div>
        </div>
        <!-- .entry-content -->
        <footer class="entry-meta">
        </footer>
        <!-- .entry-meta -->
       </article>
       <!-- #post -->
       <div class="comments-area" id="comments">
       </div>
       <!-- #comments -->
      </div>
      <!-- #content -->
     </div>
     <!-- #primary -->
     <div class="sidebar-container" id="tertiary" role="complementary">
      <div class="sidebar-inner">
       <div class="widget-area">
        <aside class="widget bbp_widget_login" id="bbp_login_widget-2">
         <h3 class="widget-title">
          登录
         </h3>
         <form action="http://cos.name/cn/wp-login.php" class="bbp-login-form" method="post">
          <fieldset>
           <legend>
            登录
           </legend>
           <div class="bbp-username">
            <label for="user_login">
             用户名:
            </label>
           </div>
           <div class="bbp-password">
            <label for="user_pass">
             密码:
            </label>
           </div>
           <div class="bbp-remember-me">
            <label for="rememberme">
             记住用户名
            </label>
           </div>
           <div class="bbp-submit-wrapper">
            <button class="button submit user-submit" id="user-submit" name="user-submit" tabindex="104" type="submit">
             登录
            </button>
           </div>
           <div class="bbp-login-links">
            <a class="bbp-register-link" href="http://cos.name/cn/wp-login.php?action=register" title="注册">
             注册
            </a>
            <a class="bbp-lostpass-link" href="http://cos.name/cn/wp-login.php?action=lostpassword" title="忘记密码">
             忘记密码
            </a>
           </div>
          </fieldset>
         </form>
        </aside>
        <aside class="widget widget_text" id="text-7">
         <h3 class="widget-title">
          搜索
         </h3>
         <div class="textwidget">
          <form action="http://www.google.com/search" id="bbp-search-form" method="get" onsubmit="Gsitesearch(this)" role="search">
           <div>
           </div>
          </form>
          <form id="bbp-search-form-baidu" onsubmit="g(this)" role="search">
           <div>
           </div>
          </form>
         </div>
        </aside>
        <aside class="widget widget_text" id="text-2">
         <h3 class="widget-title">
          新鲜事
         </h3>
         <div class="textwidget">
          <ul>
           <li>
            <a href="http://cos.name/cn/topics/">
             最新帖子
            </a>
           </li>
           <li>
            <a href="http://cos.name/cn/view/popular/">
             最热门主题
            </a>
           </li>
           <li>
            <a href="http://cos.name/cn/view/no-replies/">
             消灭零回复
            </a>
           </li>
          </ul>
         </div>
        </aside>
        <aside class="widget widget_text" id="text-3">
         <h3 class="widget-title">
          RSS订阅
         </h3>
         <div class="textwidget">
          <ul>
           <li>
            <img src="http://cos.name/wp-includes/images/rss.png"/>
            <a href="http://cos.name/cn/topics/feed/">
             所有主题
            </a>
           </li>
           <li>
            <img src="http://cos.name/wp-includes/images/rss.png"/>
            <a href="http://cos.name/cn/forums/feed/">
             所有帖子
            </a>
           </li>
          </ul>
         </div>
        </aside>
       </div>
       <!-- .widget-area -->
      </div>
      <!-- .sidebar-inner -->
     </div>
     <!-- #tertiary -->
    </div>
    <!-- #main -->
    <footer class="site-footer" id="colophon" role="contentinfo">
     <div class="site-info">
      版权所有 © 2014 统计之都 | 由
      <a href="http://wordpress.org/">
       WordPress
      </a>
      构建 | 主题修改自
      <a href="http://wordpress.org/themes/twentythirteen">
       Twenty Thirteen
      </a>
     </div>
     <!-- .site-info -->
    </footer>
    <!-- #colophon -->
   </div>
   <!-- #page -->
  </div>
 </body>
</html>